package cn.itcast.controller;

import cn.itcast.pojo.ItemDoc;
import cn.itcast.pojo.PageResult;
import cn.itcast.pojo.RequestParams;
import cn.itcast.service.ISearchService;

import com.hmall.common.dto.PageDTO;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Queue;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private ISearchService iSearchService;
    //自动补全
@GetMapping("suggestion")
    public List<String>getSuggestion(@RequestParam("key")String key){
    return iSearchService.getSuggestion(key);
}
//聚合
@PostMapping("/filters")
public Map<String, List<String>> getFilters(@RequestBody RequestParams params){
    return iSearchService.getFilters(params);
}
//搜索

    @PostMapping("/list")
    public PageDTO<ItemDoc> search(@RequestBody RequestParams params) throws IOException {
    return iSearchService.search(params);
    }


}
